package com.liuke.question4.handler;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.PipedInputStream;

/**
 * @Auther: 刘科
 * @Date: 2021/07/04/10:34
 * @Description:
 */
public class StdoutPipeHandler extends AbstractPipeHandler {
    public StdoutPipeHandler(PipedInputStream inputStream) {
        super(inputStream, null);
    }

    @Override
    protected void handle(BufferedReader reader) {
        StringBuilder sb = new StringBuilder();
        String line;
        try {
            while ((line = reader.readLine()) != null) {
                sb.append(line).append("\n");
            }
            System.out.println(sb.toString());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void closeOutStream() {
        throw new UnsupportedOperationException("不支持关闭");
    }
}
